package com.ruoyi.bom.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bom.domain.ErpBomChange;
import com.ruoyi.bom.service.IErpBomChangeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * BOM变更表Controller
 * 
 * @author ruoyi
 * @date 2025-08-22
 */
@RestController
@RequestMapping("/bom/erp_bom_change")
public class ErpBomChangeController extends BaseController
{
    @Autowired
    private IErpBomChangeService erpBomChangeService;

    /**
     * 查询BOM变更表列表
     */
    @PreAuthorize("@ss.hasPermi('bom:erp_bom_change:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpBomChange erpBomChange)
    {
        startPage();
        List<ErpBomChange> list = erpBomChangeService.selectErpBomChangeList(erpBomChange);
        return getDataTable(list);
    }

    /**
     * 导出BOM变更表列表
     */
    @PreAuthorize("@ss.hasPermi('bom:erp_bom_change:export')")
    @Log(title = "BOM变更表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpBomChange erpBomChange)
    {
        List<ErpBomChange> list = erpBomChangeService.selectErpBomChangeList(erpBomChange);
        ExcelUtil<ErpBomChange> util = new ExcelUtil<ErpBomChange>(ErpBomChange.class);
        util.exportExcel(response, list, "BOM变更表数据");
    }

    /**
     * 获取BOM变更表详细信息
     */
    @PreAuthorize("@ss.hasPermi('bom:erp_bom_change:query')")
    @GetMapping(value = "/{documentNo}")
    public AjaxResult getInfo(@PathVariable("documentNo") Long documentNo)
    {
        return success(erpBomChangeService.selectErpBomChangeByDocumentNo(documentNo));
    }

    /**
     * 新增BOM变更表
     */
    @PreAuthorize("@ss.hasPermi('bom:erp_bom_change:add')")
    @Log(title = "BOM变更表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpBomChange erpBomChange)
    {
        return toAjax(erpBomChangeService.insertErpBomChange(erpBomChange));
    }

    /**
     * 修改BOM变更表
     */
    @PreAuthorize("@ss.hasPermi('bom:erp_bom_change:edit')")
    @Log(title = "BOM变更表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpBomChange erpBomChange)
    {
        return toAjax(erpBomChangeService.updateErpBomChange(erpBomChange));
    }

    /**
     * 删除BOM变更表
     */
    @PreAuthorize("@ss.hasPermi('bom:erp_bom_change:remove')")
    @Log(title = "BOM变更表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{documentNos}")
    public AjaxResult remove(@PathVariable Long[] documentNos)
    {
        return toAjax(erpBomChangeService.deleteErpBomChangeByDocumentNos(documentNos));
    }
}
